package com.zhuifeng.product.service.impl;

import com.zhuifeng.jsoup.JsoupHtml;
import com.zhuifeng.product.domain.Goods;
import com.zhuifeng.product.mapper.GoodsMapper;
import com.zhuifeng.product.service.GoodsService;
import com.zhuifeng.utils.ExcelUtils;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    private final GoodsMapper goodsMapper;

    public GoodsServiceImpl(GoodsMapper goodsMapper) {
        this.goodsMapper = goodsMapper;
    }

    @Override
    public void goodsInsert() throws IOException {

        List<Goods> html = JsoupHtml.getHtml();



        ExcelUtils.writeToExcel("D:\\study\\excel\\1.xls",Goods.class,"爬虫爬的数据",html);

    }

    @Override
    public void goodsExcel() {

        List<Goods> goods = ExcelUtils.readFromExcelName("D:\\study\\excel\\1.xls", Goods.class, 0);

        goodsMapper.goodsInsert(goods);
    }
}
